#include <QDebug>
#include "cg_autre.h"
#include "cg_partie.h"
#include "cg_tapis.h"
#include "cg_grandtapis.h"
#include "cg_jeuadversaire.h"
#include "cg_jeujoueur.h"

Cg_Partie::Cg_Partie() : QGraphicsScene(0,0,1920,1080), m_clientJeu(0), m_numeroJoueur(0)
{
    unsigned int i = 0;
    for (i = 0 ; i < 5 ; i++)
    {
        m_boutonsAnnonces[i] = 0;
        if (i<4)
        {
            m_boutonsCouleurs[i] = 0;
            m_boutonsFigures[i] = 0;
        }
    }
}

Cg_Partie::Cg_Partie(ClientJeu *clientJeu) : QGraphicsScene(0,0,1920,1080), m_clientJeu(clientJeu), m_numeroJoueur(0)
{
    unsigned int i = 0;
    for (i = 0 ; i < 5 ; i++)
    {
        m_boutonsAnnonces[i] = 0;
        if (i<4)
        {
            m_boutonsCouleurs[i] = 0;
            m_boutonsFigures[i] = 0;
        }
    }
    Cg_Tapis *tapis = new Cg_Tapis();
    m_tapis = tapis;
    QObject::connect(m_clientJeu, SIGNAL(carte_jouee(unsigned int, Carte)), tapis, SLOT(carte_jouee(unsigned int , Carte)));
    QObject::connect(m_clientJeu, SIGNAL(numero_change(unsigned int)), tapis, SLOT(numero_change(unsigned int)));
    QObject::connect(m_clientJeu, SIGNAL(requete_refusee(Carte)), tapis, SLOT(requete_refusee(Carte)));
    QObject::connect(m_clientJeu, SIGNAL(adversaires(std::vector<std::string>)), tapis, SLOT(adversaires(std::vector<std::string>)));
    QObject::connect(m_clientJeu, SIGNAL(pli_termine(unsigned int)), tapis, SLOT(pli_termine(unsigned int)));
    QObject::connect(m_clientJeu, SIGNAL(chien(Carte, Carte, Carte)), tapis, SLOT(chien(Carte, Carte, Carte)));
    QObject::connect(m_clientJeu, SIGNAL(contrat_final(Enchere)), tapis, SLOT(contrat_final(Enchere)));
    QObject::connect(m_clientJeu, SIGNAL(ecart_accepte(std::vector<Carte>)), tapis, SLOT(ecart_accepte(std::vector<Carte>)));

    Cg_GrandTapis *grandTapis = new Cg_GrandTapis();
    m_grandTapis = grandTapis;
    QObject::connect(m_clientJeu, SIGNAL(carte_jouee(unsigned int, Carte)), grandTapis, SLOT(carte_jouee(unsigned int , Carte)));
    QObject::connect(tapis, SIGNAL(dernierPli(QVector<QPixmap>)), grandTapis, SLOT(dernierPli(QVector<QPixmap>)));
    QObject::connect(m_clientJeu, SIGNAL(numero_change(unsigned int)), grandTapis, SLOT(numero_change(unsigned int)));
    QObject::connect(m_clientJeu, SIGNAL(adversaires(std::vector<std::string>)), grandTapis, SLOT(adversaires(std::vector<std::string>)));
    QObject::connect(m_clientJeu, SIGNAL(pli_termine(unsigned int)), grandTapis, SLOT(pli_termine(unsigned int)));
    QObject::connect(m_clientJeu, SIGNAL(doit_jouer()), grandTapis, SLOT(doit_jouer()));
    QObject::connect(m_clientJeu, SIGNAL(maitre_change(unsigned int)), grandTapis, SLOT(maitre_change(unsigned int)));
    QObject::connect(m_clientJeu, SIGNAL(contrat_intermediaire(Enchere)), grandTapis, SLOT(contrat_intermediaire(Enchere)));
    QObject::connect(m_clientJeu, SIGNAL(contrat_final(Enchere)), grandTapis, SLOT(contrat_final(Enchere)));
    QObject::connect(m_clientJeu, SIGNAL(doit_identifier()), grandTapis, SLOT(doit_identifier()));
    QObject::connect(grandTapis, SIGNAL(formuler_identification(std::string)), m_clientJeu, SLOT(formuler_identification(std::string)));

    Cg_JeuJoueur *jeu1 = new Cg_JeuJoueur();
    m_jeuJoueur = jeu1;
    QObject::connect(m_clientJeu, SIGNAL(numero_change(unsigned int)), jeu1, SLOT(numero_change(unsigned int)));

    Cg_JeuAdversaire *jeu2 = new Cg_JeuAdversaire(2);
    m_jeuxAdversaires[0] = jeu2;
    QObject::connect(m_clientJeu, SIGNAL(carte_jouee(unsigned int, Carte)), jeu2, SLOT(carte_jouee(unsigned int, Carte)));

    Cg_JeuAdversaire *jeu3 = new Cg_JeuAdversaire(3);
    m_jeuxAdversaires[1] = jeu3;
    QObject::connect(m_clientJeu, SIGNAL(carte_jouee(unsigned int, Carte)), jeu3, SLOT(carte_jouee(unsigned int, Carte)));

    Cg_JeuAdversaire *jeu4 = new Cg_JeuAdversaire(4);
    m_jeuxAdversaires[2] = jeu4;
    QObject::connect(m_clientJeu, SIGNAL(carte_jouee(unsigned int, Carte)), jeu4, SLOT(carte_jouee(unsigned int, Carte)));

    Cg_JeuAdversaire *jeu5 = new Cg_JeuAdversaire(5);
    m_jeuxAdversaires[3] = jeu5;
    QObject::connect(m_clientJeu, SIGNAL(carte_jouee(unsigned int, Carte)), jeu5, SLOT(carte_jouee(unsigned int, Carte)));
    addItem(tapis);
    addItem(grandTapis);
}

void Cg_Partie::adversaires(std::vector<std::string> noms)
{
    Q_UNUSED(noms)
    unsigned int i = 0;
    for (i = 0; i < 15; i++)
    {
        Cg_CarteAdverse *carteAdverse1 = new Cg_CarteAdverse(m_jeuxAdversaires[0],i);
        addItem(carteAdverse1);

        Cg_CarteAdverse *carteAdverse2 = new Cg_CarteAdverse(m_jeuxAdversaires[1],i);
        addItem(carteAdverse2);

        Cg_CarteAdverse *carteAdverse3 = new Cg_CarteAdverse(m_jeuxAdversaires[2],i);
        addItem(carteAdverse3);

        Cg_CarteAdverse *carteAdverse4 = new Cg_CarteAdverse(m_jeuxAdversaires[3],i);
        addItem(carteAdverse4);
    }
    m_jeuJoueur->update();
    QPixmap rien;
    for (i = 0 ; i < 4 ; i ++)
    {  
        m_jeuxAdversaires[i]->update();
        QGraphicsPixmapItem *carte = new QGraphicsPixmapItem(rien);
        m_pliJoueur[i] = carte;
    }
    QGraphicsPixmapItem *carte = new QGraphicsPixmapItem(rien);
    m_pliJoueur[4] = carte;
}

void Cg_Partie::numero_change(unsigned int n)
{
    m_numeroJoueur = n;
}

void Cg_Partie::requete_refusee(Carte posee)
{
    qDebug() << "requete_refusee - Cg_Partie\n";
    Cg_CarteJoueur *carte = new Cg_CarteJoueur(posee.numero(), m_jeuJoueur);
    addItem(carte);
    m_jeuJoueur->update();
}

void Cg_Partie::pli_termine(unsigned int joueur)
{
    qDebug() << "pli_termine - Cg_Partie\n";
    if (m_pliJoueur[joueur]->pixmap().isNull())
    {
        QPixmap carte;
        QTransform t;
        qreal angle = 0, x = 1300, y = 855;
        carte.load(":/images/Dos de Carte (Govi).png");
        unsigned int s = (joueur - m_numeroJoueur + 5) % 5;
        switch (s)
        {
            case 0 :
            {
                carte.load(":/images/Dos de Carte (Govi) 2.png");
                break;
            }

            case 1 :
            {
                angle = 327;
                x = 1745, y = 207;
                break;
            }

            case 2 :
            {
                angle = 274;
                x = 1060, y = 32;
                break;
            }

            case 3 :
            {
                angle = 193;
                x = 313, y = 233;
                break;
            }

            case 4 :
            {
                angle = 134;
                x = 110, y = 884;
                break;
            }
        }
        t.rotate(angle);
        m_pliJoueur[joueur]->setPixmap(carte.transformed(t,Qt::SmoothTransformation));
        m_pliJoueur[joueur]->setOffset(x,y);
        addItem(m_pliJoueur[joueur]);
    }
}

void Cg_Partie::doit_priser(Option<Enchere> max)
{
    QFont font("Bodoni MT", 30);
    QPushButton *passe = new QPushButton("Passe",0);
    passe->setGeometry(811,429,298,63);
    passe->setFont(font);
    QGraphicsProxyWidget *p_passe = addWidget(passe);
    m_boutonsAnnonces[0] = passe;
    p_passe->setZValue(16);
    QPushButton *prise = new QPushButton("Prise", 0);
    prise->setGeometry(638,517,298,63);
    prise->setFont(font);
    QGraphicsProxyWidget *p_prise = addWidget(prise);
    m_boutonsAnnonces[1] = prise;
    p_prise->setZValue(16);
    QPushButton *garde = new QPushButton("Garde", 0);
    garde->setGeometry(985,517,298,63);
    garde->setFont(font);
    QGraphicsProxyWidget *p_garde = addWidget(garde);
    m_boutonsAnnonces[2] = garde;
    p_garde->setZValue(16);
    QPushButton *gardeSans = new QPushButton("Garde-Sans", 0);
    gardeSans->setGeometry(638,612,298,63);
    gardeSans->setFont(font);
    QGraphicsProxyWidget *p_gardeSans = addWidget(gardeSans);
    m_boutonsAnnonces[3] = gardeSans;
    p_gardeSans->setZValue(16);
    QPushButton *gardeContre = new QPushButton("Garde-Contre", 0);
    gardeContre->setGeometry(985,612,298,63);
    gardeContre->setFont(font);
    QGraphicsProxyWidget *p_gardeContre = addWidget(gardeContre);
    m_boutonsAnnonces[4] = gardeContre;
    p_gardeContre->setZValue(16);
    if (max.aucun())
    {

    }
    else
    {
        Enchere::Prise p = max.get().prise();
        if (p>Enchere::PASSE)
        {
            prise->setEnabled(false);
        }
        if (p>Enchere::PRISE)
        {
            garde->setEnabled(false);
        }
        if (p>Enchere::GARDE)
        {
            gardeSans->setEnabled(false);
        }
        if (p>Enchere::GARDE_SANS)
        {
            gardeContre->setEnabled(false);
        }
    }
    connect(passe, SIGNAL(clicked()), this, SLOT(formulerPasse()));
    connect(prise, SIGNAL(clicked()), this, SLOT(formulerPrise()));
    connect(garde, SIGNAL(clicked()), this, SLOT(formulerGarde()));
    connect(gardeSans, SIGNAL(clicked()), this, SLOT(formulerGardeSans()));
    connect(gardeContre, SIGNAL(clicked()), this, SLOT(formulerGardeContre()));
}

void Cg_Partie::enchere_acceptee(Enchere e)
{
    Q_UNUSED(e)
    unsigned int i = 0;
    for (i = 0 ; i < 5 ; i++)
    {
        m_boutonsAnnonces[i]->deleteLater();
    }
}

void Cg_Partie::doit_appeler(std::vector<Carte> acceptees)
{
    QFont font("Bodoni MT", 20);
    QPushButton *roi = new QPushButton("Roi");
    roi->setGeometry(700,300,100,50);
    roi->setFont(font);
    QGraphicsProxyWidget *p_roi = addWidget(roi);
    m_boutonsFigures[0] = roi;
    p_roi->setZValue(16);
    QPushButton *dame = new QPushButton("Dame", 0);
    dame->setGeometry(850,300,100,50);
    dame->setFont(font);
    QGraphicsProxyWidget *p_dame = addWidget(dame);
    m_boutonsFigures[1] = dame;
    p_dame->setZValue(16);
    QPushButton *cavalier = new QPushButton("Cavalier", 0);
    cavalier->setGeometry(1000,300,100,50);
    cavalier->setFont(font);
    QGraphicsProxyWidget *p_cavalier = addWidget(cavalier);
    m_boutonsFigures[2] = cavalier;
    p_cavalier->setZValue(16);
    QPushButton *valet = new QPushButton("Valet", 0);
    valet->setGeometry(1150,300,100,50);
    valet->setFont(font);
    QGraphicsProxyWidget *p_valet = addWidget(valet);
    m_boutonsFigures[3] = valet;
    p_valet->setZValue(16);
    if (acceptees.size()<13)
    {
        valet->setEnabled(false);
    }
    if (acceptees.size()<9)
    {
        cavalier->setEnabled(false);
    }
    if (acceptees.size()<5)
    {
        dame->setEnabled(false);
    }
    connect(roi, SIGNAL(clicked()), this, SLOT(appelRoi()));
    connect(dame, SIGNAL(clicked()), this, SLOT(appelDame()));
    connect(cavalier, SIGNAL(clicked()), this, SLOT(appelCavalier()));
    connect(valet, SIGNAL(clicked()), this, SLOT(appelValet()));
    appelRoi();
}

void Cg_Partie::appel_accepte(Carte c)
{
    Q_UNUSED(c)
    unsigned int i = 0;
    for (i = 0 ; i < 4 ; i++)
    {
        delete(m_boutonsCouleurs[i]);
        delete(m_boutonsFigures[i]);
    }
}

void Cg_Partie::chien(Carte c1, Carte c2, Carte c3)
{
    m_chien[0] = c1;
    m_chien[1] = c2;
    m_chien[2] = c3;
}

void Cg_Partie::doit_ecarter(std::vector<Carte> possibles, std::vector<Carte> atouts)
{
    Q_UNUSED(possibles)
    Q_UNUSED(atouts)
    m_chien[0] = Carte(78);
    m_chien[1] = Carte(78);
    m_chien[2] = Carte(78);
}

void Cg_Partie::carteAuChien(Carte c)
{
    if (m_chien[0].numero() == 78)
    {
        m_chien[0] = c;
    }
    else
    {
        if (m_chien[1].numero() == 78)
        {
            m_chien[1] = c;
        }
        else
        {
            if (m_chien[2].numero() == 78)
            {
                m_chien[2] = c;
                std::vector<Carte> ecart;
                ecart.push_back(m_chien[0]);
                ecart.push_back(m_chien[1]);
                ecart.push_back(m_chien[2]);
                emit formuler_ecart(ecart);
            }
        }
    }

}

void Cg_Partie::jeu_est(std::vector<Carte> cartes)
{
    qDebug() << "jeu_est - Cg_Partie\n";
    int unsigned i = 0;
    m_jeuJoueur->effacerJeu();
    for (i = 0; i < cartes.size(); i++)
    {
        Cg_CarteJoueur *carteJoueur = new Cg_CarteJoueur(cartes[i].numero(),m_jeuJoueur,i);
        QObject::connect(carteJoueur, SIGNAL(formuler_requete(Carte)), m_clientJeu, SLOT(formuler_requete(Carte)));
        QObject::connect(carteJoueur, SIGNAL(carteAuChien(Carte)), this, SLOT(carteAuChien(Carte)));
        QObject::connect(m_clientJeu, SIGNAL(doit_jouer()), carteJoueur, SLOT(doit_jouer()));
        QObject::connect(m_clientJeu, SIGNAL(doit_ecarter(std::vector<Carte>, std::vector<Carte>)), carteJoueur, SLOT(doit_ecarter(std::vector<Carte>, std::vector<Carte>)));
        addItem(carteJoueur);
    }
    m_jeuJoueur->update();
}

void Cg_Partie::partie_terminee(std::vector<int> scores)
{
    unsigned int i = 0;
    for (i = 0 ; i < 5 ; i++)
    {
        removeItem(m_pliJoueur[i]);
    }
}

void Cg_Partie::formulerPasse()
{
    emit formuler_prise(Enchere::PASSE);
}

void Cg_Partie::formulerPrise()
{
    emit formuler_prise(Enchere::PRISE);
}

void Cg_Partie::formulerGarde()
{
    emit formuler_prise(Enchere::GARDE);
}

void Cg_Partie::formulerGardeSans()
{
    emit formuler_prise(Enchere::GARDE_SANS);
}

void Cg_Partie::formulerGardeContre()
{
    emit formuler_prise(Enchere::GARDE_CONTRE);
}

void Cg_Partie::appelRoi()
{
    unsigned int i = 0;
    for (i = 0 ; i < 4 ; i++)
    {
        delete(m_boutonsCouleurs[i]);
    }
    QPushButton *coeur = new QPushButton("", 0);
    coeur->setGeometry(648,465,115,216);
    coeur->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Roi de Coeur.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_coeur = addWidget(coeur);
    m_boutonsCouleurs[0] = coeur;
    p_coeur->setZValue(16);
    QPushButton *carreau = new QPushButton("", 0);
    carreau->setGeometry(818,465,115,216);
    carreau->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Roi de Carreau.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_carreau = addWidget(carreau);
    m_boutonsCouleurs[1] = carreau;
    p_carreau->setZValue(16);
    QPushButton *pique = new QPushButton("", 0);
    pique->setGeometry(988,465,115,216);
    pique->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Roi de Pique.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_pique = addWidget(pique);
    m_boutonsCouleurs[2] = pique;
    p_pique->setZValue(16);
    QPushButton *trefle = new QPushButton("", 0);
    trefle->setGeometry(1158,465,115,216);
    trefle->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Roi de Trefle.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_trefle = addWidget(trefle);
    m_boutonsCouleurs[3] = trefle;
    p_trefle->setZValue(16);
    connect(coeur, SIGNAL(clicked()), this, SLOT(appelRoiCoeur()));
    connect(carreau, SIGNAL(clicked()), this, SLOT(appelRoiCarreau()));
    connect(pique, SIGNAL(clicked()), this, SLOT(appelRoiPique()));
    connect(trefle, SIGNAL(clicked()), this, SLOT(appelRoiTrefle()));
}

void Cg_Partie::appelDame()
{
    unsigned int i = 0;
    for (i = 0 ; i < 4 ; i++)
    {
        delete(m_boutonsCouleurs[i]);
    }
    QPushButton *coeur = new QPushButton("", 0);
    coeur->setGeometry(648,465,115,216);
    coeur->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Dame de Coeur.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_coeur = addWidget(coeur);
    m_boutonsCouleurs[0] = coeur;
    p_coeur->setZValue(16);
    QPushButton *carreau = new QPushButton("", 0);
    carreau->setGeometry(818,465,115,216);
    carreau->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Dame de Carreau.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_carreau = addWidget(carreau);
    m_boutonsCouleurs[1] = carreau;
    p_carreau->setZValue(16);
    QPushButton *pique = new QPushButton("", 0);
    pique->setGeometry(988,465,115,216);
    pique->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Dame de Pique.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_pique = addWidget(pique);
    m_boutonsCouleurs[2] = pique;
    p_pique->setZValue(16);
    QPushButton *trefle = new QPushButton("", 0);
    trefle->setGeometry(1158,465,115,216);
    trefle->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Dame de Trefle.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_trefle = addWidget(trefle);
    m_boutonsCouleurs[3] = trefle;
    p_trefle->setZValue(16);
    connect(coeur, SIGNAL(clicked()), this, SLOT(appelDameCoeur()));
    connect(carreau, SIGNAL(clicked()), this, SLOT(appelDameCarreau()));
    connect(pique, SIGNAL(clicked()), this, SLOT(appelDamePique()));
    connect(trefle, SIGNAL(clicked()), this, SLOT(appelDameTrefle()));
}

void Cg_Partie::appelCavalier()
{
    unsigned int i = 0;
    for (i = 0 ; i < 4 ; i++)
    {
       delete( m_boutonsCouleurs[i]);
    }
    QPushButton *coeur = new QPushButton("", 0);
    coeur->setGeometry(648,465,115,216);
    coeur->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Cavalier de Coeur.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_coeur = addWidget(coeur);
    m_boutonsCouleurs[0] = coeur;
    p_coeur->setZValue(16);
    QPushButton *carreau = new QPushButton("", 0);
    carreau->setGeometry(818,465,115,216);
    carreau->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Cavalier de Carreau.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_carreau = addWidget(carreau);
    m_boutonsCouleurs[1] = carreau;
    p_carreau->setZValue(16);
    QPushButton *pique = new QPushButton("", 0);
    pique->setGeometry(988,465,115,216);
    pique->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Cavalier de Pique.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_pique = addWidget(pique);
    m_boutonsCouleurs[2] = pique;
    p_pique->setZValue(16);
    QPushButton *trefle = new QPushButton("", 0);
    trefle->setGeometry(1158,465,115,216);
    trefle->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Cavalier de Trefle.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_trefle = addWidget(trefle);
    m_boutonsCouleurs[3] = trefle;
    p_trefle->setZValue(16);
    connect(coeur, SIGNAL(clicked()), this, SLOT(appelCavalierCoeur()));
    connect(carreau, SIGNAL(clicked()), this, SLOT(appelCavalierCarreau()));
    connect(pique, SIGNAL(clicked()), this, SLOT(appelCavalierPique()));
    connect(trefle, SIGNAL(clicked()), this, SLOT(appelCavalierTrefle()));
}

void Cg_Partie::appelValet()
{
    unsigned int i = 0;
    for (i = 0 ; i < 4 ; i++)
    {
        delete(m_boutonsCouleurs[i]);
    }
    QPushButton *coeur = new QPushButton("", 0);
    coeur->setGeometry(648,465,115,216);
    coeur->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Valet de Coeur.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_coeur = addWidget(coeur);
    m_boutonsCouleurs[0] = coeur;
    p_coeur->setZValue(16);
    QPushButton *carreau = new QPushButton("", 0);
    carreau->setGeometry(818,465,115,216);
    carreau->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Valet de Carreau.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_carreau = addWidget(carreau);
    m_boutonsCouleurs[1] = carreau;
    p_carreau->setZValue(16);
    QPushButton *pique = new QPushButton("", 0);
    pique->setGeometry(988,465,115,216);
    pique->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Valet de Pique.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_pique = addWidget(pique);
    m_boutonsCouleurs[2] = pique;
    p_pique->setZValue(16);
    QPushButton *trefle = new QPushButton("", 0);
    trefle->setGeometry(1158,465,115,216);
    trefle->setStyleSheet("QPushButton { background-color: transparent; border-image: url(:/images/Valet de Trefle.png) 3 10 3 10; border-top: 3px transparent; border-bottom: 3px transparent; border-right: 10px transparent; border-left: 10px transparent;}");
    QGraphicsProxyWidget *p_trefle = addWidget(trefle);
    m_boutonsCouleurs[3] = trefle;
    p_trefle->setZValue(16);
    connect(coeur, SIGNAL(clicked()), this, SLOT(appelValetCoeur()));
    connect(carreau, SIGNAL(clicked()), this, SLOT(appelValetCarreau()));
    connect(pique, SIGNAL(clicked()), this, SLOT(appelValetPique()));
    connect(trefle, SIGNAL(clicked()), this, SLOT(appelValetTrefle()));
}

void Cg_Partie::appelRoiCoeur()
{
    emit formuler_appel(Carte(13));
}

void Cg_Partie::appelRoiCarreau()
{
    emit formuler_appel(Carte(41));
}

void Cg_Partie::appelRoiPique()
{
    emit formuler_appel(Carte(27));
}

void Cg_Partie::appelRoiTrefle()
{
    emit formuler_appel(Carte(55));
}

void Cg_Partie::appelDameCoeur()
{
    emit formuler_appel(Carte(12));
}

void Cg_Partie::appelDameCarreau()
{
    emit formuler_appel(Carte(40));
}

void Cg_Partie::appelDamePique()
{
    emit formuler_appel(Carte(26));
}

void Cg_Partie::appelDameTrefle()
{
    emit formuler_appel(Carte(55));
}

void Cg_Partie::appelCavalierCoeur()
{
    emit formuler_appel(Carte(11));
}

void Cg_Partie::appelCavalierCarreau()
{
    emit formuler_appel(Carte(39));
}

void Cg_Partie::appelCavalierPique()
{
    emit formuler_appel(Carte(25));
}

void Cg_Partie::appelCavalierTrefle()
{
    emit formuler_appel(Carte(54));
}

void Cg_Partie::appelValetCoeur()
{
    emit formuler_appel(Carte(9));
}

void Cg_Partie::appelValetCarreau()
{
    emit formuler_appel(Carte(38));
}

void Cg_Partie::appelValetPique()
{
    emit formuler_appel(Carte(24));
}

void Cg_Partie::appelValetTrefle()
{
    emit formuler_appel(Carte(53));
}
